// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using Elastic.Transport.Extensions;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.MachineLearning;

public sealed partial class StartTrainedModelDeploymentRequestParameters : RequestParameters
{
	/// <summary>
	/// <para>
	/// The inference cache size (in memory outside the JVM heap) per node for the model.
	/// The default value is the same size as the <c>model_size_bytes</c>. To disable the cache,
	/// <c>0b</c> can be provided.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.ByteSize? CacheSize { get => Q<Elastic.Clients.Elasticsearch.ByteSize?>("cache_size"); set => Q("cache_size", value); }

	/// <summary>
	/// <para>
	/// A unique identifier for the deployment of the model.
	/// </para>
	/// </summary>
	public string? DeploymentId { get => Q<string?>("deployment_id"); set => Q("deployment_id", value); }

	/// <summary>
	/// <para>
	/// The number of model allocations on each node where the model is deployed.
	/// All allocations on a node share the same copy of the model in memory but use
	/// a separate set of threads to evaluate the model.
	/// Increasing this value generally increases the throughput.
	/// If this setting is greater than the number of hardware threads
	/// it will automatically be changed to a value less than the number of hardware threads.
	/// </para>
	/// </summary>
	public int? NumberOfAllocations { get => Q<int?>("number_of_allocations"); set => Q("number_of_allocations", value); }

	/// <summary>
	/// <para>
	/// The deployment priority.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.MachineLearning.TrainingPriority? Priority { get => Q<Elastic.Clients.Elasticsearch.MachineLearning.TrainingPriority?>("priority"); set => Q("priority", value); }

	/// <summary>
	/// <para>
	/// Specifies the number of inference requests that are allowed in the queue. After the number of requests exceeds
	/// this value, new requests are rejected with a 429 error.
	/// </para>
	/// </summary>
	public int? QueueCapacity { get => Q<int?>("queue_capacity"); set => Q("queue_capacity", value); }

	/// <summary>
	/// <para>
	/// Sets the number of threads used by each model allocation during inference. This generally increases
	/// the inference speed. The inference process is a compute-bound process; any number
	/// greater than the number of available hardware threads on the machine does not increase the
	/// inference speed. If this setting is greater than the number of hardware threads
	/// it will automatically be changed to a value less than the number of hardware threads.
	/// </para>
	/// </summary>
	public int? ThreadsPerAllocation { get => Q<int?>("threads_per_allocation"); set => Q("threads_per_allocation", value); }

	/// <summary>
	/// <para>
	/// Specifies the amount of time to wait for the model to deploy.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }

	/// <summary>
	/// <para>
	/// Specifies the allocation status to wait for before returning.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.MachineLearning.DeploymentAllocationState? WaitFor { get => Q<Elastic.Clients.Elasticsearch.MachineLearning.DeploymentAllocationState?>("wait_for"); set => Q("wait_for", value); }
}

/// <summary>
/// <para>
/// Start a trained model deployment.
/// It allocates the model to every machine learning node.
/// </para>
/// </summary>
public sealed partial class StartTrainedModelDeploymentRequest : PlainRequest<StartTrainedModelDeploymentRequestParameters>
{
	public StartTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id modelId) : base(r => r.Required("model_id", modelId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningStartTrainedModelDeployment;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => false;

	internal override string OperationName => "ml.start_trained_model_deployment";

	/// <summary>
	/// <para>
	/// The inference cache size (in memory outside the JVM heap) per node for the model.
	/// The default value is the same size as the <c>model_size_bytes</c>. To disable the cache,
	/// <c>0b</c> can be provided.
	/// </para>
	/// </summary>
	[JsonIgnore]
	public Elastic.Clients.Elasticsearch.ByteSize? CacheSize { get => Q<Elastic.Clients.Elasticsearch.ByteSize?>("cache_size"); set => Q("cache_size", value); }

	/// <summary>
	/// <para>
	/// A unique identifier for the deployment of the model.
	/// </para>
	/// </summary>
	[JsonIgnore]
	public string? DeploymentId { get => Q<string?>("deployment_id"); set => Q("deployment_id", value); }

	/// <summary>
	/// <para>
	/// The number of model allocations on each node where the model is deployed.
	/// All allocations on a node share the same copy of the model in memory but use
	/// a separate set of threads to evaluate the model.
	/// Increasing this value generally increases the throughput.
	/// If this setting is greater than the number of hardware threads
	/// it will automatically be changed to a value less than the number of hardware threads.
	/// </para>
	/// </summary>
	[JsonIgnore]
	public int? NumberOfAllocations { get => Q<int?>("number_of_allocations"); set => Q("number_of_allocations", value); }

	/// <summary>
	/// <para>
	/// The deployment priority.
	/// </para>
	/// </summary>
	[JsonIgnore]
	public Elastic.Clients.Elasticsearch.MachineLearning.TrainingPriority? Priority { get => Q<Elastic.Clients.Elasticsearch.MachineLearning.TrainingPriority?>("priority"); set => Q("priority", value); }

	/// <summary>
	/// <para>
	/// Specifies the number of inference requests that are allowed in the queue. After the number of requests exceeds
	/// this value, new requests are rejected with a 429 error.
	/// </para>
	/// </summary>
	[JsonIgnore]
	public int? QueueCapacity { get => Q<int?>("queue_capacity"); set => Q("queue_capacity", value); }

	/// <summary>
	/// <para>
	/// Sets the number of threads used by each model allocation during inference. This generally increases
	/// the inference speed. The inference process is a compute-bound process; any number
	/// greater than the number of available hardware threads on the machine does not increase the
	/// inference speed. If this setting is greater than the number of hardware threads
	/// it will automatically be changed to a value less than the number of hardware threads.
	/// </para>
	/// </summary>
	[JsonIgnore]
	public int? ThreadsPerAllocation { get => Q<int?>("threads_per_allocation"); set => Q("threads_per_allocation", value); }

	/// <summary>
	/// <para>
	/// Specifies the amount of time to wait for the model to deploy.
	/// </para>
	/// </summary>
	[JsonIgnore]
	public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }

	/// <summary>
	/// <para>
	/// Specifies the allocation status to wait for before returning.
	/// </para>
	/// </summary>
	[JsonIgnore]
	public Elastic.Clients.Elasticsearch.MachineLearning.DeploymentAllocationState? WaitFor { get => Q<Elastic.Clients.Elasticsearch.MachineLearning.DeploymentAllocationState?>("wait_for"); set => Q("wait_for", value); }
}

/// <summary>
/// <para>
/// Start a trained model deployment.
/// It allocates the model to every machine learning node.
/// </para>
/// </summary>
public sealed partial class StartTrainedModelDeploymentRequestDescriptor : RequestDescriptor<StartTrainedModelDeploymentRequestDescriptor, StartTrainedModelDeploymentRequestParameters>
{
	internal StartTrainedModelDeploymentRequestDescriptor(Action<StartTrainedModelDeploymentRequestDescriptor> configure) => configure.Invoke(this);

	public StartTrainedModelDeploymentRequestDescriptor(Elastic.Clients.Elasticsearch.Id modelId) : base(r => r.Required("model_id", modelId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningStartTrainedModelDeployment;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => false;

	internal override string OperationName => "ml.start_trained_model_deployment";

	public StartTrainedModelDeploymentRequestDescriptor CacheSize(Elastic.Clients.Elasticsearch.ByteSize? cacheSize) => Qs("cache_size", cacheSize);
	public StartTrainedModelDeploymentRequestDescriptor DeploymentId(string? deploymentId) => Qs("deployment_id", deploymentId);
	public StartTrainedModelDeploymentRequestDescriptor NumberOfAllocations(int? numberOfAllocations) => Qs("number_of_allocations", numberOfAllocations);
	public StartTrainedModelDeploymentRequestDescriptor Priority(Elastic.Clients.Elasticsearch.MachineLearning.TrainingPriority? priority) => Qs("priority", priority);
	public StartTrainedModelDeploymentRequestDescriptor QueueCapacity(int? queueCapacity) => Qs("queue_capacity", queueCapacity);
	public StartTrainedModelDeploymentRequestDescriptor ThreadsPerAllocation(int? threadsPerAllocation) => Qs("threads_per_allocation", threadsPerAllocation);
	public StartTrainedModelDeploymentRequestDescriptor Timeout(Elastic.Clients.Elasticsearch.Duration? timeout) => Qs("timeout", timeout);
	public StartTrainedModelDeploymentRequestDescriptor WaitFor(Elastic.Clients.Elasticsearch.MachineLearning.DeploymentAllocationState? waitFor) => Qs("wait_for", waitFor);

	public StartTrainedModelDeploymentRequestDescriptor ModelId(Elastic.Clients.Elasticsearch.Id modelId)
	{
		RouteValues.Required("model_id", modelId);
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
	}
}